import numpy as np
import eigen_solver  # type: ignore # 导入编译好的模块
import h5py
import sys
# 读取数据
with h5py.File("C3D8_Static_pre.h5", "r") as f:
    Kg=f['Kg'][:]
    Kg_bc=f['Kg_bc'][:]
    F_bc=f['F_bc'][:]

print("Kg shape:",type(Kg))
print("Kg_bc shape:",Kg_bc.shape)
print("F_bc shape:",F_bc.shape)
input("Press any key to continue...")
import timeit
start = timeit.default_timer()
# 调用函数,计算节点位移,计算时间
U=eigen_solver.solve_linear_system(Kg_bc,F_bc)
F=Kg@U
stop = timeit.default_timer()
print('Time: ', stop - start)

# 保存结果
with h5py.File("C3D8_Static_post.h5", "w") as f:
    f.create_dataset("U_py", data=U)
    f.create_dataset("F_py", data=F)

# 时间:186.18s